export default function getPromise({ url, type, data }) {
    return new Promise((resolve, reject) => {
        $.ajax({
                url,
                type,
                data,
               headers:{
                Authorization:localStorage.token
            },
            success(msg) {
                resolve(msg)
            },
            error(err) {
                reject(err)
                // 验证失败会进入
                if(err.status == 401){
                    // token验证失败
                    localStorage.removeItem("token")
                    localStorage.removeItem("userId")
                    window.location.href="../login.html";
                }
            }
        })
    })
}
